<template>
  <div id="recommend">
    <div class="title">编辑推荐</div>
    <ul>
      <template v-for="item in recArr">
          <router-link :key="item.id" tag="li" :to="`/songsheet/${item.id}`">
          <div>
            <i class="iconfont icon-erji"></i>
            <span>{{ (item.playCount / 10000).toFixed(1) }}万</span>
          </div>
          <img :src="item.picUrl" />
          <p>{{ item.name }}</p>
          </router-link>
      </template>
    </ul>
    <div class="title">最新音乐</div>
    <musicinfo :infoArr="infoArr"></musicinfo>
    <footer>
      <div>
        <i class="iconfont icon-xigua"> <span>西瓜音乐</span></i>
        <a>打开App，发现更多好音乐</a>
        <p>西瓜公司版权所有©1997-2021 杭州乐读科技有限公司运营</p>
      </div>
    </footer>
  </div>
</template>

<script>
import musicinfo from "../../components/MusicInfo.vue";
export default {
  data: () => {
    return {
      recArr: JSON.parse(localStorage.getItem("recArr")) || [],
      infoArr: JSON.parse(localStorage.getItem("infoArr")) || [],
    };
  },

  async mounted() {
    // this._axios.get("/top/playlist/highquality").then((res) => {
    //   console.log(res);
    // });
    let res = await this._axios.get("/personalized");
    this.recArr = res.data.result.splice(0, 6);

    let res1 = await this._axios.get("/personalized/newsong");
    this.infoArr = res1.data.result;
    console.log(this.recArr);
    console.log(this.infoArr);
  },
  watch: {
    recArr() {
      localStorage.setItem("recArr", JSON.stringify(this.recArr));
    },
    infoArr() {
      localStorage.setItem("infoArr", JSON.stringify(this.infoArr));
    },
  },
  components: {
    musicinfo,
  },
};
</script>

<style lang="scss" scoped>
#recommend {
  .title {
    height: _vw(37);
    border-left: 2px solid red;
    font-size: _vw(36);
    padding-left: _vw(18);
    margin: _vw(30) 0;
  }
  ul {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: _vw(35);
    li {
      position: relative;
      width: _vw(245);
      height: _vw(340);
      img {
        width: _vw(245);
        height: _vw(250);
      }
      div {
        color: #fff;
        right: _vw(5);
        top: _vw(2);
        position: absolute;
        font-size: _vw(16);
        i{
          font-size: _vw(13);
        }
  
      }
      p {
        font-size: _vw(25);
        margin: 0 _vw(5);
        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }
    }
  }
  footer {
    height: _vw(410);
    div {
      height: _vw(410);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      i {
        font-size: _vw(70);
      }
      a {
        margin: _vw(10) 0;
        display: inline-block;
        display: flex;
        align-items: center;
        justify-content: center;
        width: _vw(620);
        height: _vw(75);
        background-color: #fff;
        border: 1px solid red;
        border-radius: 25px;
      }
      p {
        font-size: _vw(17);
      }
    }
  }
}
</style>